#include <AST/expr/literal/StringPtrAST.hpp>
#include <global.hpp>

StringPtr::StringPtr(string val) : val(std::move(val)) {
    cachedValue = builder.CreateGlobalString(this->val, "g_StrPtr", 0, &theModule);
    printf("create StringPtr\n");
}

llvm::Type *StringPtr::getType() {
    return cachedValue->getType();
}

llvm::Constant *StringPtr::codegen() {
    return static_cast<Constant *>(cachedValue);
}

llvm::Constant *StringPtr::getDefault() {
    static Constant *const emptyString_Ptr =
        builder.CreateGlobalString("", "g_emptyStrPtr", 0, &theModule);
    return emptyString_Ptr;
}
